Repository navigation
fix: 企业/Workspace 账号无用量窗口时跳过用量校验,避免导入被误判未登录 - #36
Merged
Mag1cFall merged 2 commits intoNov 27, 2026
Merged
Conversation
Contributor
Author
|
补充一句:如需复现或验证此问题,我这边可以提供一个教育版 Workspace 账号配合测试,需要时请在本 PR 回复告知即可,账号信息私下提供、不在公开页面贴出。 |
Owner
|
感谢PR,Workspace 账号导入失败确实是真问题(#34),已合入,不过补了一个提交 3fab2b6 改掉了不少地方,说一下取舍: 保留的:
改掉的:
简单说就是为了让导入一定能过把错误全吞了,这类兜底我不收。账号不用提供了,用故障注入在本地复现过了,会随 v0.2.2 发布~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
企业 / Workspace 版 Gemini 账号在导入时失败:
该类账号官网没有五小时 / 每周用量窗口,用量 RPC(
jSf9Qc)返回空数据。decodeUsageResponse把「空 payload」和「响应中无用量记录」都归为errUsageNotSignedIn,且以下三处把FetchUsage失败当作硬失败,导致账号明明已登录也被拒绝:chromeauth.validateAndWriteImportsaccounts.initializegemini.reload该问题在独立版与下游 CPA 插件版(jianli9158/cpa-plugin-gemini-web2api,核心代码移植自本仓库)中均存在;下游已先行部署此修复并实测企业账号可正常导入,本 PR 将同一修复提交回源头。
改动
internal/gemini/usage.goErrUsageUnavailable:空 payload、无用量记录、用量数据解析失败统一归为此类,不再等同未登录(真正的未登录仍由Init的首页 bootstrapSNlM0e校验拦截,不放宽登录校验);FetchUsage遇此类错误返回 Tier=unknown、无用量窗口的空用量并视为成功,上下文窗口不做本地限制;parseUsageInfo对「有套餐、无用量窗口行」保留套餐直接放行。internal/chromeauth/auth.go、internal/accounts/manager.go、internal/gemini/rotate.go测试
internal/gemini/usage_test.go4 个用例:空 payload →ErrUsageUnavailable、无用量记录 →ErrUsageUnavailable、有套餐无窗口 → 放行保留套餐、正常个人账号窗口 → 解析不变。go test ./internal/gemini/全包通过(含既有测试),改动涉及的三个包go build与go vet均干净。(注:go build ./...中internal/webui需要前端 dist 产物,与本次改动无关。)说明
本 PR 不含任何账号凭证 / Cookie 信息。